package jmine.tec.web.front.domain;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Transient;

import jmine.tec.persist.annotation.DiscriminatorComment;

import org.hibernate.annotations.Type;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

import bancosys.tec.component.Documentation;
import bancosys.tec.utils.date.Date;

/**
 * Back office request value of type date
 * 
 * @author lundberg
 */
@Entity
@DiscriminatorValue("2")
@DiscriminatorComment("DATE")
public class BackOfficeRequestValueDate extends BackOfficeRequestValue<Date> {

    /**
     * Constructor
     */
    public BackOfficeRequestValueDate() {
    }

    /**
     * Constructor
     * 
     * @param property property
     * @param value value
     */
    public BackOfficeRequestValueDate(BackOfficeRequestProperty property, Date value) {
        super(property, value);
    }

    /**
     * @return value
     */
    @Type(type = "bancosys.tec.persist.hibernate.type.DateType")
    @Column(name = "VL_DATA")
    @Documentation("VALOR DA PROPRIEDADE DO TIPO DATA.")
    protected Date getDateValue() {
        return this.getValue();
    }

    /**
     * @param stringValue the value to set
     */
    protected void setDateValue(Date stringValue) {
        this.setValue(stringValue);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    @Transient
    public Criterion getCriteriaExpression() {
        return Restrictions.eq("dateValue", this.getDateValue());
    }

}
